package com.adapter.objectadapter;


/**
 * @author zhupanlin
 * @version 1.0
 * @description: TODO
 * @date 2024/4/15 8:39
 */
// 适配器类
public class VoltageAdapter implements IVoltage5V {

    public VoltageAdapter(Voltage220V voltage220V) {
        this.voltage220V = voltage220V;
    }

    public VoltageAdapter() {
        
    }

    private Voltage220V voltage220V = new Voltage220V();
    
    @Override
    public int output5V() {
        int dst = 0;
        if (voltage220V == null){
            System.out.println("适配失败");
            return dst;
        }
        // 获取220V电压
        int src = voltage220V.output220V();
        System.out.println("使用对象适配器，进行适配");
        dst = src / 44;
        System.out.println("适配完成，输出电压为 : " + dst);
        
        return dst;
    }
}
